import numpy as np
import pandas as pd

# 创建数据
s = pd.Series([1, 2, 3, np.nan, 3, 4, 5, 5, 5, 5, np.nan, np.nan,
               6, 6, 7, 12, 2, np.nan, 3, 3])

# 均值填充
u = s.mean()
fill_mean = s.fillna(u)

# 中位数填充
me = s.median()
fill_median = s.fillna(me)

# 众数填充
mod = s.mode()
x = mod.tolist()[0]  # 此时得到的众数有3和5，选择第一个众数进行填充
fill_mode = s.fillna(x)
